package com.yuanhe.yunoj.judge.codeSandbox;

import com.yuanhe.yunoj.judge.codeSandbox.model.ExecuteCodeRequest;
import com.yuanhe.yunoj.judge.codeSandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 代理模式(不用改变原始的代码情况下对其进行一些功能增强)
 */
@Slf4j
public class CodeSandboxProxy implements CodeSandbox {
    private final CodeSandbox codeSandbox;

    public CodeSandboxProxy(CodeSandbox codeSandbox) {
        this.codeSandbox = codeSandbox;
    }

    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("调用代码沙箱前请求信息 :" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("调用代码沙箱后请求信息 :" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
